package com.clwl.supervise.superviseapp.service.inspect;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clwl.supervise.superviseapp.mapper.base.TcCompanyMapper;
import com.clwl.supervise.superviseapp.util.UserHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

@Service
public class IntelligentTaskService {

    @Resource
    private TcCompanyMapper companyMapper;


    /**
     * 体系检查列表信息
     * @param pageNum
     * @param pageSize
     * @param sortType 1-按时限；2-按任务多少；3-按发现问题；4-按风险高低
     * @param sortOrder 正序还是倒序 1-正序；2-倒序
     * @return
     */
    public IPage<Map<String, Object>> getTaskList(Integer pageNum, Integer pageSize, Integer sortType, Integer sortOrder) {

        Long deptId = UserHelper.getUserInfo().getDeptId();
        Page<Map<String, Object>> iPage = Page.of(pageNum, pageSize);
        iPage.setOptimizeCountSql(false);
        iPage.setSearchCount(false);
        switch (sortType){
            case 1:
                return companyMapper.selectIntelligentTaskTimeOrderList(iPage, deptId,  sortOrder);
            case 2:
                return null;
            case 3:
                return companyMapper.selectIntelligentTaskProblemCountList(iPage, deptId,  sortOrder);
            case 4:
                return companyMapper.selectIntelligentTaskRiskList(iPage, deptId,  sortOrder);
            default:
                return companyMapper.selectIntelligentTaskTimeOrderList(iPage, deptId,  sortOrder);
        }
    }
}
